const {get} = require('http')

function waitOn(port = 1314, interval = 1000) {
    return new Promise(function (resolve) {
        const url = `http://localhost:${port}`
        //监听vue项目是否启动
        let timer = setInterval(() => {
            get(
                url,
                function (res) {
                    clearInterval(timer)
                    timer =null
                    resolve(res.statusCode)
                }
            ).on('error', function () {
                // console.log('持续监控中，前台项目暂未启动')
            })
        }, interval)
    })
}
module.exports.waitOn = waitOn